<?php

require_once('db/db.php');

$db=new DB;

function check($name){
	if(isset($_REQUEST[$name])){
		return $_REQUEST[$name];
	}
	else{
		die();
	}
}

$id=intval(check('id'));
$name=check('name');
$product_link=check('product_link');
$pic_link=check('pic_link');
$desc=check('desc');
$click_counts=check('click_counts');
$love_counts=check('love_counts');
$category=check('category');
$discount=check('discount');
$price=check('price');
$prime_price=check('prime_price');



$sql = "update `product` set `name`='$name',`product_link`='$product_link',`pic_link`='$pic_link',`desc`='$desc',`click_counts`='$click_counts',`love_counts`='$love_counts',
							 `category`='$category',`discount`='$discount',`price`='$price',`prime_price`='$prime_price' where `id`=$id";

echo $sql;
if(!$db->query($sql)){
	die();
}

echo json_encode(array(
	'id' => $id,
	'name' => $name,
	'product_link' => $product_link,
	'pic_link' => $pic_link,
	'desc' => $desc,
	'click_counts' => $click_counts,
	'love_counts' => $love_counts,
	'category' => $category,
	'discount' => $discount,
	'price' => $price,
	'prime_price' => $prime_price
));

?>
